function imageSmoother(img: number[][]): number[][] {
    const row = img.length
    const col = img[0].length

    const ans: number[][] = new Array(row).fill(0).map(_ => new Array(col).fill(0)) 

    for (let i = 0; i < row; i++) {
        for (let j = 0; j < col; j++) {
            const rightColBoundary = Math.min(j + 1, col - 1)
            const leftColBoundary = Math.max(j - 1, 0)
            const topColBoundary = Math.max(i - 1, 0)
            const bottomColBoundary = Math.min(i + 1, row - 1)
            let total = 0
            for (let x = topColBoundary; x <= bottomColBoundary; x++) {
                for (let y = leftColBoundary; y <= rightColBoundary; y++) {
                    total += img[x][y]
                }
            }
            ans[i][j] = Math.floor(total / ((bottomColBoundary - topColBoundary + 1) * (rightColBoundary - leftColBoundary + 1)))
        } 
    }


    return ans
};

// (1, 1)
// (0, 0), (0, 1), (0, 2)
// (1, 0)          (1, 2)
// (2, 0), (2, 1), (2, 2)